package com.wr.hangzhounewlight.service.frontend;

import com.wr.hangzhounewlight.mapper.OrderMapper;
import com.wr.hangzhounewlight.mapper.RecipeMapper;
import com.wr.hangzhounewlight.obj.dto.frontend.R;
import com.wr.hangzhounewlight.obj.dto.frontend.RecipeListDTO;
import com.wr.hangzhounewlight.obj.vo.frontend.RecipeListVO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yuanzhizhuo
 * createDate 2025/11/14
 */
@Service
public class RecipeListService {

    private final OrderMapper orderMapper;
    private final RecipeMapper recipeMapper;

    public RecipeListService(OrderMapper orderMapper, RecipeMapper recipeMapper) {
        this.orderMapper = orderMapper;
        this.recipeMapper = recipeMapper;
    }

    public R queryRecipeList(RecipeListDTO dto) {
        List<RecipeListVO> voList = orderMapper.selectOrderVO(dto).stream().peek(vo ->
            vo.setRecipeList(recipeMapper.selectRecipeVO(vo.getOrderId()))
        ).toList();
        return new R(200, "success", voList);
    }

}
